<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>socket.c</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/prettify.js"></script><script language=JavaScript src="../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.52 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CFile"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="socket.c"></a>socket.c</h1><div class=CBody><p>Author: onteria_</p><p>Created on April 30, 2011, 7:11 AM</p><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#socket.c" >socket.c</a></td><td class=SDescription>Author: onteria_</td></tr><tr class="SGroup"><td class=SEntry><a href="#Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#miko_read_socket" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">miko_read_socket</a></td><td class=SDescription>Reads nbyte bytes of data from a file descriptor fd into the buffer pointed to by buf. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#miko_create_socket6" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">miko_create_socket6</a></td><td class=SDescription>Create an IPV6 socket from a given port and address. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#miko_create_socket" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">miko_create_socket</a></td><td class=SDescription>Create an IPV4 socket from a given port and address. </td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="miko_read_socket"></a>miko_read_socket</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>extern long miko_read_socket(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>fd,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>void&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>buf,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>size_t&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>nbyte,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>timeout</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Reads nbyte bytes of data from a file descriptor fd into the buffer pointed to by buf.&nbsp; Shows error if the read failed for any reason.&nbsp; Uses poll() to provide connection timeout functionality.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>fd</td><td class=CDLDescription>File descriptor of the socket</td></tr><tr><td class=CDLEntry>buf</td><td class=CDLDescription>The buffer to hold the value</td></tr><tr><td class=CDLEntry>nbyte</td><td class=CDLDescription>The number of bytes to read</td></tr><tr><td class=CDLEntry>timeout</td><td class=CDLDescription>The socket timeout value</td></tr></table><h4 class=CHeading>Returns</h4><p>The total bytes read equal to nbyte, or POLLERROR if there was an error with poll TIMEOUT if the connection timed out</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="miko_create_socket6"></a>miko_create_socket6</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>extern struct sockaddr_in6 miko_create_socket6(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>port,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>char&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>address</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create an IPV6 socket from a given port and address.&nbsp; Uses getaddrinfo since it&rsquo;s IPV6 friendly.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>port</td><td class=CDLDescription>The port to use</td></tr><tr><td class=CDLEntry>address</td><td class=CDLDescription>The address of the host</td></tr></table><h4 class=CHeading>Returns</h4><p>An IPV6 socket or NULL if there was an error</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="miko_create_socket"></a>miko_create_socket</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>extern struct sockaddr_in miko_create_socket(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>port,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>char&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>address</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create an IPV4 socket from a given port and address.&nbsp; Uses getaddrinfo since it&rsquo;s IPV6 friendly.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>port</td><td class=CDLDescription>The port to use</td></tr><tr><td class=CDLEntry>address</td><td class=CDLDescription>The address of the host</td></tr></table><h4 class=CHeading>Returns</h4><p>An IPV4 socket or NULL if there was an error</p></div></div></div>

</div><!--Content-->


<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->


<div id=Menu><div class=MEntry><div class=MFile><a href="protocol-c.html">protocol.c</a></div></div><div class=MEntry><div class=MFile id=MSelected>socket.c</div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Index</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MIndex><a href="../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Files.html">Files</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Functions.html">Functions</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option  id=MSearchEverything selected value="General">Everything</option><option value="Files">Files</option><option value="Functions">Functions</option></select></div></div><!--Menu-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>extern long miko_read_socket(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>fd,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>void&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>buf,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>size_t&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>nbyte,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>timeout</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Reads nbyte bytes of data from a file descriptor fd into the buffer pointed to by buf. </div></div><div class=CToolTip id="tt2"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>extern struct sockaddr_in6 miko_create_socket6(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>port,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>char&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>address</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create an IPV6 socket from a given port and address. </div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>extern struct sockaddr_in miko_create_socket(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>port,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>char&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>address</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create an IPV4 socket from a given port and address. </div></div><!--END_ND_TOOLTIPS-->




<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>


<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>